﻿(function ($) {
    $.equinfojs = {

        //保存新增设备类型
        saveEquType: function (EquTypeName, EquTypeRemark, EquIndex, grid) {

            $.ajax({
                url: "./EquInfo.ashx",
                data: {
                    Action: "addEquTypeInfo",
                    EquTypeName: EquTypeName,
                    EquTypeRemark: EquTypeRemark,
                    EquIndex: EquIndex
                },
                type: "post",
                async: true,
                datatype: "json",
                success: function (data) {
                    if (data == "success") {
                        Loading(false);
                        dialogMsg("保存成功", 1);
                        grid.trigger("reloadGrid");
                        dialogClose();
                    }
                    else if (data == "falut") {
                        dialogMsg("保存失败", -1);
                    }
                    else if (data == "hasexit") {
                        dialogMsg("已存在此设备类型", 0);
                    }

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    Loading(false);
                    dialogMsg(errorThrown, -1);
                },
                beforeSend: function () {
                    Loading(true, "正在保存数据");
                },
                complete: function () {
                    Loading(false);
                }
            });
        },

        /// 保存新增设备类型   带有设备类型特性
        saveEquTypeWithTexing: function (EquTypeName, EquTypeRemark, EquIndex, EquTypeTexingID, grid) {

            $.ajax({
                url: "./EquInfo.ashx",
                data: JSON.stringify({
                    Action: "saveEquTypeWithTexing",
                    EquTypeName: EquTypeName,
                    EquTypeRemark: EquTypeRemark,
                    EquIndex: EquIndex,
                    EquTypeTexingID: EquTypeTexingID
                }),
                type: "post",
                async: true,
                datatype: "json",
                success: function (data) {
                    if (data == "success") {
                        Loading(false);
                        dialogMsg("保存成功", 1);
                        grid.trigger("reloadGrid");
                        dialogClose();
                    }
                    else if (data == "falut") {
                        dialogMsg("保存失败", -1);
                    }
                    else if (data == "hasexit") {
                        dialogMsg("已存在此设备类型", 0);
                    }

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    Loading(false);
                    dialogMsg(errorThrown, -1);
                },
                beforeSend: function () {
                    Loading(true, "正在保存数据");
                },
                complete: function () {
                    Loading(false);
                }
            });
        },

        //初始化设备类型信息  设备卡号新增界面 初始化select
        initEquTypeList: function () {

            $("#EquType").empty();
            var optionstring = "";
            $.ajax({
                url: "../Equipment/EquInfo.ashx",
                data: {
                    Action: "initEquTypeList"
                },
                async: true,
                type: "post",
                datatype: "json",
                success: function (data) {
                    Loading(false);
                    data = JSON.parse(data);
                    console.log(data);
                    if (data.length > 0) {
                        for (i in data) {
                            optionstring += "<option value=\"" + data[i].EquTypeName + "\" >" + data[i].EquTypeName.trim() + "</option>";
                        }
                        $("#EquType").html("<option value=''>请选择</option>" + optionstring);
                    }
                    else
                        dialogMsg(data.msg, -1);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    Loading(false);
                    dialogMsg(errorThrown, -1);
                }
            });
        },

        //保存新设备卡号信息
        saveEquKaoHao: function (EquNo, EquType, Remark, grid) {

            $.ajax({
                url: "./EquInfo.ashx",
                data: {
                    Action: "addEquKaoHao",
                    EquNo: EquNo,
                    EquType: EquType,
                    Remark: Remark
                },
                type: "post",
                async: true,
                datatype: "json",
                success: function (data) {
                    if (data == "success") {
                        Loading(false);
                        dialogMsg("保存成功", 1);
                        grid.trigger("reloadGrid");
                        dialogClose();
                    }
                    else if (data == "falut") {
                        dialogMsg("保存失败", -1);
                    }
                    else if (data == "hasexit") {
                        dialogMsg("已存在此设备卡号", 0);
                    }

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    Loading(false);
                    dialogMsg(errorThrown, -1);
                },
                beforeSend: function () {
                    Loading(true, "正在保存数据");
                },
                complete: function () {
                    Loading(false);
                }
            });
        },

        //设置纺纱品种
        savefangshakind: function (TaiHao,EquNo, FangShaKind, FangShaDate, CustomerID, grid) {

            $.ajax({
                url: "./EquInfo.ashx",
                data: {
                    Action: "savefangshakind",
                    TaiHao: TaiHao,
                    EquNo: EquNo,
                    FangShaKind: FangShaKind,
                    FangShaDate: FangShaDate,
                    CustomerID: CustomerID
                },
                type: "post",
                async: true,
                datatype: "json",
                success: function (data) {
                    if (data == "success") {
                        Loading(false);
                        dialogMsg("保存成功", 1);
                        grid.trigger("reloadGrid");
                        dialogClose();
                    }
                    else if (data == "falut") {
                        dialogMsg("保存失败", -1);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    Loading(false);
                    dialogMsg(errorThrown, -1);
                },
                beforeSend: function () {
                    Loading(true, "正在保存数据");
                },
                complete: function () {
                    Loading(false);
                }
            });
        },

        //根据ID获取纺纱信息
        initfangshabyid: function (FangshaID) {
            $.ajax({
                url: "./EquInfo.ashx",
                data: {
                    Action: "initfangshabyid",
                    FangshaID: FangshaID
                },
                async: true,
                type: "post",
                datatype: "json",
                success: function (data) {
                    Loading(false);
                    data = JSON.parse(data);
                    console.log(data);
                    if (data.length > 0) {
                        $("#FangShaKind").val(data[0].FangShaKind);
                        $("#OutPutTarget").val(data[0].OutPutTarget);
                        $("#FangShaDate").val(data[0].FangShaDate);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    Loading(false);
                    dialogMsg(errorThrown, -1);
                }
            });
        },

        //生产设置新增纺纱品种
        saveShengChanfangshakind: function (CustomerID, FangShaKind, OutPutTarget, FangShaDate, CustomerID, grid) {

            $.ajax({
                url: "./EquInfo.ashx",
                data: {
                    Action: "saveShengChanfangshakind",
                    FangShaKind: FangShaKind,
                    OutPutTarget: OutPutTarget,
                    FangShaDate: FangShaDate,
                    CustomerID: CustomerID
                },
                type: "post",
                async: true,
                datatype: "json",
                success: function (data) {
                    if (data == "success") {
                        Loading(false);
                        dialogMsg("保存成功", 1);
                        grid.trigger("reloadGrid");
                        dialogClose();
                    }
                    else if (data == "falut") {
                        dialogMsg("保存失败", -1);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    Loading(false);
                    dialogMsg(errorThrown, -1);
                },
                beforeSend: function () {
                    Loading(true, "正在保存数据");
                },
                complete: function () {
                    Loading(false);
                }
            });
        },

        //生产设置编辑纺纱品种
        editShengChanfangshakind: function (ID, FangShaKind, OutPutTarget, FangShaDate, CustomerID, grid) {
            $.ajax({
                url: "./EquInfo.ashx",
                data: {
                    Action: "editShengChanfangshakind",
                    FangShaKind: FangShaKind,
                    OutPutTarget: OutPutTarget,
                    FangShaDate: FangShaDate,
                    ID: ID
                },
                type: "post",
                async: true,
                datatype: "json",
                success: function (data) {
                    if (data == "success") {
                        Loading(false);
                        dialogMsg("保存成功", 1);
                        grid.trigger("reloadGrid");
                        dialogClose();
                    }
                    else if (data == "falut") {
                        dialogMsg("保存失败", -1);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    Loading(false);
                    dialogMsg(errorThrown, -1);
                },
                beforeSend: function () {
                    Loading(true, "正在保存数据");
                },
                complete: function () {
                    Loading(false);
                }
            });
        },

        //初始化生产设置纺纱品种信息
        initShengChanSetInfo: function (CustomerID) {
            //加载表格
            var selectedRowIndex = 0;
            var $gridTable = $('#gridTable');
            $gridTable.jqGrid({
                postData: {
                    Action: "initShengChanSetInfo",
                    CustomerID: CustomerID
                },
                url: "./EquInfo.ashx",
                datatype: "json",
                height: $(window).height() - 136.5,
                autowidth: true,
                colModel: [
                    { label: '主键', name: 'ID', hidden: true },
                    { label: '车间名称', name: 'CustomeName', index: 'CustomeName', width: 200, align: 'left' },
                    { label: '纺纱品种', name: 'FangShaKind', index: 'FangShaKind', width: 200, align: 'left' },
                    { label: '纺纱日期', name: 'FangShaDate', index: 'FangShaDate', width: 200, align: 'left' },
                    { label: '目标产量(T)', name: 'OutPutTarget', index: 'OutPutTarget', width: 300, align: 'left' },
                    { label: '更新时间', name: 'UpdateTime', index: 'UpdateTime', width: 300, align: 'left' },
                ],
                viewrecords: true,
                rowNum: 1000000,
                rownumbers: true,
                shrinkToFit: false,
                gridview: true,
                onSelectRow: function () {
                    selectedRowIndex = $("#" + this.id).getGridParam('selrow');
                },
                gridComplete: function () {
                    $("#" + this.id).setSelection(selectedRowIndex, false);
                }
            });
        },

        //删除设备类型信息
        deleteEquTypeInfo: function (TypeID, FeatureID, grid) {
            $.ajax({
                url: "./EquInfo.ashx",
                data: {
                    Action: "deleteEquTypeInfo",
                    TypeID: TypeID,
                    FeatureID: FeatureID
                },
                type: "post",
                async: true,
                datatype: "json",
                success: function (data) {
                    console.log(data);
                    if (data == "success") {
                        Loading(false);
                        dialogMsg("删除成功", 1);
                        grid.trigger("reloadGrid");
                        dialogClose();
                    }
                    else if (data == "falut") {
                        dialogMsg("删除失败", -1);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    Loading(false);
                    dialogMsg(errorThrown, -1);
                },
                beforeSend: function () {
                    Loading(true, "正在保存数据");
                },
                complete: function () {
                    Loading(false);
                }
            });
        },

        //删除设备类型信息
        deleteEquTypeInfoguidao: function (ID,  grid) {
            $.ajax({
                url: "./EquInfo.ashx",
                data: {
                    Action: "deleteEquTypeInfoguidao",
                    ID: ID
                },
                type: "post",
                async: true,
                datatype: "json",
                success: function (data) {
                    console.log(data);
                    if (data == "success") {
                        Loading(false);
                        dialogMsg("删除成功", 1);
                        grid.trigger("reloadGrid");
                        dialogClose();
                    }
                    else if (data == "falut") {
                        dialogMsg("删除失败", -1);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    Loading(false);
                    dialogMsg(errorThrown, -1);
                },
                beforeSend: function () {
                    Loading(true, "正在保存数据");
                },
                complete: function () {
                    Loading(false);
                }
            });
        },

        //初始化设备类型 编辑界面
        initeditequtype: function (TypeID, FeatureID) {

            $.ajax({
                url: "./EquInfo.ashx",
                data: {
                    Action: "initeditequtype",
                    TypeID: TypeID,
                    FeatureID: FeatureID
                },
                async: true,
                type: "post",
                datatype: "json",
                success: function (data) {
                    Loading(false);
                    data = JSON.parse(data);
                    console.log(data);
                    if (data.length > 0) {
                        $("#EquTypeName").val(data[0].EquTypeName);
                        $("#EquTypeRemark").val(data[0].EquTypeRemark);
                        $("#EquTypeFeatures").val(data[0].EquTypeFeatures);
                        $("#FeaturesContent").val(data[0].FeaturesContent);
                        $("#MaintenanceCycle").val(data[0].MaintenanceCycle);
                        $("#ChangeEquNo").val(data[0].ChangeEquNo);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    Loading(false);
                    dialogMsg(errorThrown, -1);
                }
            });
        },

        // 保存编辑  设备类型
        editequtype: function (TypeID, FeatureID, EquTypeName, EquTypeRemark, EquIndex, EquTypeFeatures, FeaturesContent, MaintenanceCycle, ChangeEquNo, grid) {

            $.ajax({
                url: "./EquInfo.ashx",
                data: {
                    Action: "editequtype",
                    TypeID: TypeID,
                    FeatureID: FeatureID,
                    EquTypeName: EquTypeName,
                    EquTypeRemark: EquTypeRemark,
                    EquIndex: EquIndex,
                    EquTypeFeatures: EquTypeFeatures,
                    FeaturesContent: FeaturesContent,
                    MaintenanceCycle: MaintenanceCycle,
                    ChangeEquNo: ChangeEquNo
                },
                type: "post",
                async: true,
                datatype: "json",
                success: function (data) {
                    if (data == "success") {
                        Loading(false);
                        dialogMsg("保存成功", 1);
                        grid.trigger("reloadGrid");
                        dialogClose();
                    }
                    else if (data == "falut") {
                        dialogMsg("保存失败", -1);
                    }
                    else if (data == "hasexit") {
                        dialogMsg("已存在此设备类型", 0);
                    }

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    Loading(false);
                    dialogMsg(errorThrown, -1);
                },
                beforeSend: function () {
                    Loading(true, "正在保存数据");
                },
                complete: function () {
                    Loading(false);
                }
            });
        },


        editequtypeguidao: function (TypeID, EquTypeName, EquTypeRemark, EquIndex, grid) {

            $.ajax({
                url: "./EquInfo.ashx",
                data: {
                    Action: "editequtypeguidao",
                    TypeID: TypeID,
                    EquTypeName: EquTypeName,
                    EquTypeRemark: EquTypeRemark,
                    EquIndex: EquIndex
                },
                type: "post",
                async: true,
                datatype: "json",
                success: function (data) {
                    if (data == "success") {
                        Loading(false);
                        dialogMsg("保存成功", 1);
                        grid.trigger("reloadGrid");
                        dialogClose();
                    }
                    else if (data == "falut") {
                        dialogMsg("保存失败", -1);
                    }
                    else if (data == "hasexit") {
                        dialogMsg("已存在此设备类型", 0);
                    }

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    Loading(false);
                    dialogMsg(errorThrown, -1);
                },
                beforeSend: function () {
                    Loading(true, "正在保存数据");
                },
                complete: function () {
                    Loading(false);
                }
            });
        },

        deleteEquInfo: function (EquID, grid) {
            $.ajax({
                url: "./EquInfo.ashx",
                data: {
                    Action: "deleteEquInfo",
                    EquID: EquID
                },
                type: "post",
                async: true,
                datatype: "json",
                success: function (data) {
                    console.log(data);
                    if (data == "success") {
                        Loading(false);
                        dialogMsg("删除成功", 1);
                        grid.trigger("reloadGrid");
                        dialogClose();
                    }
                    else if (data == "falut") {
                        dialogMsg("删除失败", -1);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    Loading(false);
                    dialogMsg(errorThrown, -1);
                },
                beforeSend: function () {
                    Loading(true, "正在保存数据");
                },
                complete: function () {
                    Loading(false);
                }
            });
        },


        //保存设备类型特性
        saveEquTypeFeature: function (EquTypeFeatures, FeaturesContent, MaintenanceCycle, grid) {

            $.ajax({
                url: "./EquInfo.ashx",
                data: {
                    Action: "saveEquTypeFeature",
                    EquTypeFeatures: EquTypeFeatures,
                    FeaturesContent: FeaturesContent,
                    MaintenanceCycle: MaintenanceCycle
                },
                type: "post",
                async: true,
                datatype: "json",
                success: function (data) {
                    if (data == "success") {
                        Loading(false);
                        dialogMsg("保存成功", 1);
                        grid.trigger("reloadGrid");
                        dialogClose();
                    }
                    else if (data == "falut") {
                        dialogMsg("保存失败", -1);
                    }

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    Loading(false);
                    dialogMsg(errorThrown, -1);
                },
                beforeSend: function () {
                    Loading(true, "正在保存数据");
                },
                complete: function () {
                    Loading(false);
                }
            });
        },

        // 得到设备类型特性列表
        getEquTypeFeatureList: function (EquTypeName) {

            //加载表格
            var selectedRowIndex = 0;
            var $gridTable = $('#gridTexing');
            $gridTable.jqGrid({
                url: "./EquInfo.ashx",
                postData: {
                    Action: "getEquTypeFeatureList",
                    EquTypeName: EquTypeName
                },
                datatype: "json",
                height: $(window).height() - 180,
                autowidth: true,
                colModel: [
                    { label: '主键', name: 'ID', hidden: true },
                    { label: '特性名称', name: 'EquTypeFeatures', index: 'EquTypeFeatures', width: 100, align: 'left' },
                    { label: '特性内容', name: 'FeaturesContent', index: 'FeaturesContent', width: 200, align: 'left' },
                    { label: '维护周期', name: 'MaintenanceCycle', index: 'MaintenanceCycle', width: 100, align: 'left' },
                ],
                viewrecords: true,
                rowNum: 30,
                rowList: [30, 50, 100],
                sortname: 'ID',
                sortable: true,
                rownumbers: true,
                shrinkToFit: false,
                gridview: true,
                onSelectRow: function () {
                    selectedRowIndex = $("#" + this.id).getGridParam('selrow');
                },
                gridComplete: function () {
                    //$("#" + this.id).setSelection(selectedRowIndex, false);
                }
            });
        },

        // 初始化设备类型特性页面
        initEquTypeFeaterEditForm: function (FeatureID) {

            $.ajax({
                url: "./EquInfo.ashx",
                data: {
                    Action: "initEquTypeFeaterEditForm",
                    FeatureID: FeatureID
                },
                async: true,
                type: "post",
                datatype: "json",
                success: function (data) {
                    Loading(false);
                    data = JSON.parse(data);
                    console.log(data);
                    if (data.length > 0) {
                        $("#EquTypeFeatures").val(data[0].EquTypeFeatures);
                        $("#FeaturesContent").val(data[0].FeaturesContent);
                        $("#MaintenanceCycle").val(data[0].MaintenanceCycle);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    Loading(false);
                    dialogMsg(errorThrown, -1);
                }
            });
        },

        // 保存编辑设备类型特性 
        editEquTypeFeature: function (FeatureID, EquTypeFeatures, FeaturesContent, MaintenanceCycle, grid) {

            $.ajax({
                url: "./EquInfo.ashx",
                data: {
                    Action: "editEquTypeFeature",
                    FeatureID: FeatureID,
                    EquTypeFeatures: EquTypeFeatures,
                    FeaturesContent: FeaturesContent,
                    MaintenanceCycle: MaintenanceCycle
                },
                type: "post",
                async: true,
                datatype: "json",
                success: function (data) {
                    if (data == "success") {
                        Loading(false);
                        dialogMsg("保存成功", 1);
                        grid.trigger("reloadGrid");
                        dialogClose();
                    }
                    else if (data == "falut") {
                        dialogMsg("保存失败", -1);
                    }

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    Loading(false);
                    dialogMsg(errorThrown, -1);
                },
                beforeSend: function () {
                    Loading(true, "正在保存数据");
                },
                complete: function () {
                    Loading(false);
                }
            });
        },

        // 新增设备类型界面  如果点击关闭按钮  就删除未分配到设备类型的特性
        deleteuntypefeature: function () {

            $.ajax({
                url: "./EquInfo.ashx",
                data: {
                    Action: "deleteuntypefeature"
                },
                type: "post",
                async: true,
                datatype: "json",
                success: function (data) {
                    console.log(data);
                    if (data == "success") {
                        Loading(false);

                    }
                    else if (data == "falut") {

                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    Loading(false);
                    dialogMsg(errorThrown, -1);
                },
                beforeSend: function () {
                    Loading(true, "正在保存数据");
                },
                complete: function () {
                    Loading(false);
                }
            });
        },


        //当是  宏大用户登录  获取设备列表信息
        initEquListByHongda: function (CustomerName) {
            //加载表格
            var selectedRowIndex = 0;
            var $gridTable = $('#gridTable');
            $gridTable.jqGrid({
                postData: {
                    Action: "initEquListByHongda",
                    keyword: $("#txt_Keyword").val(),
                    CustomerName: CustomerName
                },
                url: "./EquInfo.ashx",
                datatype: "json",
                height: $(window).height() - 136.5,
                autowidth: true,
                colModel: [
                    { label: '主键', name: 'ID', hidden: true },
                    { label: '设备铭牌号', name: 'EquNo', index: 'EquNo', width: 200, align: 'left' },
                    { label: '设备类型', name: 'EquType', index: 'EquType', width: 200, align: 'left' },
                    { label: '建立时间', name: 'CreateTime', index: 'CreateTime', width: 300, align: 'left' },
                    { label: '购买厂商', name: 'CustomName', index: 'CustomName', width: 300, align: 'left' },
                    { label: '台号', name: 'TaiHao', index: 'TaiHao', width: 100, align: 'center' },
                    { label: '初始时间', name: 'UseDate', index: 'UseDate', width: 150, align: 'center' },
                    { label: '备注', name: 'Remark', index: 'Remark', width: 200, align: 'left' },
                ],
                viewrecords: true,
                rowNum: 30,
                rowList: [30, 50, 100],
                sortname: 'ID',
                sortable: true,
                pager: "#gridPager",
                rownumbers: false,
                shrinkToFit: false,
                gridview: true,
                onSelectRow: function () {
                    selectedRowIndex = $("#" + this.id).getGridParam('selrow');
                },
                gridComplete: function () {
                    $("#" + this.id).setSelection(selectedRowIndex, false);
                }
            });
        },


        //当是 客户登录 获取所购设备列表
        initEquListByCustomerID: function (CustomerName) {
            //加载表格
            var selectedRowIndex = 0;
            var $gridTable = $('#gridTable');
            $gridTable.jqGrid({
                postData: {
                    Action: "initEquListByCustomerID",
                    keyword: $("#txt_Keyword").val(),
                    CustomerName: CustomerName
                },
                url: "./EquInfo.ashx",
                datatype: "json",
                height: $(window).height() - 136.5,
                autowidth: false,
                colModel: [
                    { label: '主键', name: 'ID', hidden: true },
                    { label: '客户ID', name: 'CustomerID', hidden: true },
                    { label: '设备铭牌号', name: 'EquNo', hidden: true },
                    { label: '台号', name: 'TaiHao', index: 'TaiHao', width: 100, align: 'center' },
                    { label: '设备铭牌号', name: 'EquNo', index: 'TaiHao', width: 100, align: 'center' },
                    { label: '设备类型', name: 'EquType', index: 'EquType', width: 200, align: 'left' },
                    { label: '纺纱品种', name: 'FangShaKind', index: 'FangShaKind', width: 300, align: 'left' },
                    { label: '纺纱品种更新时间', name: 'UpdateTime', index: 'UpdateTime', width: 300, align: 'left' },
                    { label: '初始时间', name: 'UseDate', index: 'UseDate', width: 150, align: 'center' },
                    { label: '维护周期', name: 'MaintenanceCycle', index: 'MaintenanceCycle', width: 200, align: 'center' },
                    { label: '最近一次维护日期', name: 'MaintenanceDate', index: 'MaintenanceDate', width: 100, align: 'center' },

                ],
                viewrecords: true,
                rowNum: 30,
                rowList: [30, 50, 100],
                sortname: 'ID',
                sortable: true,
                pager: "#gridPager",
                rownumbers: false,
                shrinkToFit: true,
                gridview: true,
                onSelectRow: function () {
                    selectedRowIndex = $("#" + this.id).getGridParam('selrow');
                },
                gridComplete: function () {
                    $("#" + this.id).setSelection(selectedRowIndex, false);
                }
            });
        },

        // 保存  编辑设备信息
        saveeditequ: function (EquNo, EquNewNo, Remark, grid) {
            $.ajax({
                url: "./EquInfo.ashx",
                data: {
                    Action: "saveeditequ",
                    EquNo: EquNo,
                    EquNewNo: EquNewNo,
                    Remark: Remark
                },
                type: "post",
                async: true,
                datatype: "json",
                success: function (data) {
                    if (data == "success") {
                        Loading(false);
                        dialogMsg("保存成功", 1);
                        grid.trigger("reloadGrid");
                        dialogClose();
                    }
                    else if (data == "falut") {
                        dialogMsg("保存失败", -1);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    Loading(false);
                    dialogMsg(errorThrown, -1);
                },
                beforeSend: function () {
                    Loading(true, "正在保存数据");
                },
                complete: function () {
                    Loading(false);
                }
            });
        },

        //设置维护周期
        saveMaintenanceCycle: function (TaiHao,EquNo, MaintenanceCycle, CustomerID, grid) {

            $.ajax({
                url: "./EquInfo.ashx",
                data: {
                    Action: "saveMaintenanceCycle",
                    TaiHao: TaiHao,
                    EquNo: EquNo,
                    MaintenanceCycle: MaintenanceCycle,
                    CustomerID: CustomerID
                },
                type: "post",
                async: true,
                datatype: "json",
                success: function (data) {
                    if (data == "success") {
                        Loading(false);
                        dialogMsg("保存成功", 1);
                        grid.trigger("reloadGrid");
                        dialogClose();
                    }
                    else if (data == "falut") {
                        dialogMsg("保存失败", -1);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    Loading(false);
                    dialogMsg(errorThrown, -1);
                },
                beforeSend: function () {
                    Loading(true, "正在保存数据");
                },
                complete: function () {
                    Loading(false);
                }
            });
        },

        //设备维护操作
        maintenanceEquInfo: function (TaiHao,EquNo, CustomerID, grid) {
            $.ajax({
                url: "./EquInfo.ashx",
                data: {
                    Action: "maintenanceEquInfo",
                    TaiHao: TaiHao,
                    EquNo: EquNo,
                    CustomerID: CustomerID
                },
                type: "post",
                async: true,
                datatype: "json",
                success: function (data) {
                    console.log(data);
                    if (data == "success") {
                        Loading(false);
                        dialogMsg("保存成功", 1);
                        grid.trigger("reloadGrid");
                        dialogClose();
                    }
                    else if (data == "falut") {
                        dialogMsg("保存失败", -1);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    Loading(false);
                    dialogMsg(errorThrown, -1);
                },
                beforeSend: function () {
                    Loading(true, "正在保存数据");
                },
                complete: function () {
                    Loading(false);
                }
            });
        },

        //初始化设备报警编辑界面
        initeditequalarm: function (AlarmID) {
            $.ajax({
                url: "./EquInfo.ashx",
                data: {
                    Action: "initeditequalarm",
                    AlarmID: AlarmID
                },
                async: true,
                type: "post",
                datatype: "json",
                success: function (data) {
                    Loading(false);
                    data = JSON.parse(data);
                    console.log(data);
                    if (data.length > 0) {
                        $("#AlarmName").val(data[0].AlarmName);
                        $("#AlarmHandle").val(data[0].AlarmHandle);
                        $("#note").val(data[0].note);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    Loading(false);
                    dialogMsg(errorThrown, -1);
                }
            });
        },

        //保存  编辑设备故障信息
        saveeditequalarm: function (AlarmID, AlarmName, AlarmHandle, note, grid) {
            $.ajax({
                url: "./EquInfo.ashx",
                data: {
                    Action: "saveeditequalarm",
                    AlarmID: AlarmID,
                    AlarmName: AlarmName,
                    AlarmHandle: AlarmHandle,
                    note: note
                },
                type: "post",
                async: true,
                datatype: "json",
                success: function (data) {
                    if (data == "success") {
                        Loading(false);
                        dialogMsg("保存成功", 1);
                        grid.trigger("reloadGrid");
                        dialogClose();
                    }
                    else if (data == "falut") {
                        dialogMsg("保存失败", -1);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    Loading(false);
                    dialogMsg(errorThrown, -1);
                },
                beforeSend: function () {
                    Loading(true, "正在保存数据");
                },
                complete: function () {
                    Loading(false);
                }
            });
        },


    };


    $(function () {

    });
})(jQuery);